package com.htgd.gardenexpo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.htgd.gardenexpo.dao.GeConGisresourceTypeDao;
import com.htgd.gardenexpo.entity.GeConGisresourceType;
import com.htgd.gardenexpo.entity.PageQuery;
import com.htgd.gardenexpo.service.GeConGisresourceTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (GeConGisresourceType)表服务实现类
 *
 * @author makejava
 * @since 2021-07-20 14:18:04
 */
@Service("geConGisresourceTypeService")
public class GeConGisresourceTypeServiceImpl implements GeConGisresourceTypeService {
    @Resource
    private GeConGisresourceTypeDao geConGisresourceTypeDao;

    @Override
    public PageInfo<GeConGisresourceType> pageList(PageQuery pageQuery) {
        PageHelper.startPage(pageQuery.getPageNum(), pageQuery.getPageSize());
        List<GeConGisresourceType> list = geConGisresourceTypeDao.pageList(pageQuery);
        return new PageInfo<>(list);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param gisResourceTypeId 主键
     * @return 实例对象
     */
    @Override
    public GeConGisresourceType queryById(Integer gisResourceTypeId) {
        return geConGisresourceTypeDao.queryById(gisResourceTypeId);
    }

    /**
     * 新增数据
     *
     * @param geConGisresourceType 实例对象
     * @return 实例对象
     */
    @Override
    public GeConGisresourceType insert(GeConGisresourceType geConGisresourceType) {
        geConGisresourceTypeDao.insert(geConGisresourceType);
        return geConGisresourceType;
    }

    /**
     * 修改数据
     *
     * @param geConGisresourceType 实例对象
     * @return 实例对象
     */
    @Override
    public GeConGisresourceType update(GeConGisresourceType geConGisresourceType) {
        geConGisresourceTypeDao.update(geConGisresourceType);
        return this.queryById(geConGisresourceType.getGisResourceTypeId());
    }

    /**
     * 通过主键删除数据
     *
     * @param gisResourceTypeId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer gisResourceTypeId) {
        return geConGisresourceTypeDao.deleteById(gisResourceTypeId) > 0;
    }
}
